/*
 * @Author: qinuoyun
 * @Date:   2019-10-30 10:12:07
 * @Last Modified by:   qinuoyun
 * @Last Modified time: 2019-10-30 10:16:04
 */
import attribute from './attribute'

import content from './index.vue'

import dataBind from '../../../plugins/data-bind'

import tool from '../../../plugins/components-tool/'


/**
 * [alert description]
 * @action       {String}    弹窗按钮
 * @content      {String}    弹窗内容
 */
let alert_form = {
  title: 'alert弹出框',
  width: '40%',
  components:'form',
  action: [{
    type: 'primary',
    label: '确定发货',
    icon: '',
    callback: {
      type:'submit',
      url: ['goods', 'on_goods_edit'],
    }
  }, {
    type: 'default',
    label: '取消发货',
    icon: '',
  }],
  content: [{
    label: "物流编号",
    type: "input",
    field: "goods_sn",
    labelWidth: "120",
    placeholder: "输入物流编号",
    span: 6
  }, {
    label: "物流名称",
    type: "select",
    field: "goods_name",
    labelWidth: "120",
    placeholder: "选择物流名称",
    span: 6,
    option:[],
    group:{
        label:'group_name',
        value:'group_id'
    },
    url:['goods','get_goods_group'],
  }]
}

let alert_table = {
  title:'详情单',
  width:'50%',
  components:"table",
  action:[{
    type: 'primary',
    label: '确定发货',
    icon: '',
  }, {
    type: 'default',
    label: '取消发货',
    icon: '',
  }],
  content:[{
    label: "商品编号",
    type: "input",
    field: "goods_sn",
    // labelWidth: "120",
    sortable: true,
  },
  {
    label: "商品名称",
    type: "input",
    field: "goods_name",
    // labelWidth: "120",
    sortable: true,
    amend: true,
    params: ['goods_id'],
  }, {
    label: "商品价格",
    type: "input",
    field: "goods_price",
    // labelWidth: "120",
    sortable: false,
    amend: true,
    params: ['goods_id'],
  }, {
    label: "封面",
    type: "image",
    field: "goods_cover",
    // labelWidth: "180",
    sortable: false,
  }]
}

/**
 * [table description]
 * @selection   {Boolean}   是否开启多选
 * @model       {String}    表格模式  popover:对话框修改    input:直接在单元格中修改
 * @label       {String}    标签
 * @type        {String}    类型
 * @field       {String}    字段
 * @option      {Array}     表格内容
 * @labelWidth  {String}    标签宽度
 * @sortable    {String}    是否排序
 * @amend       {Boolean}   是否直接修改   
 * @tips        {Boolean}   是否添加头部说明
 * @headTips    {Object}    头部提示内容  tips:true  方才有效
 * @filters     {Array}     表头筛选功能   
 */


export default {
  attribute: {
    header: [{
      label: '表头1',
      field: '',
      labelWidth: 0,
      sort: false,
      type: 'input',
      tips: false,
      headTips: "提示！",
      amend: false,
      params: ['goods_id'],
      filters: [],
      option:{},           //  必须存在
    }, {
      label: '表头2',
      field: '',
      labelWidth: 0,
      sort: false,
      type: 'input',
      tips: false,
      headTips: "提示！",
      amend: false,
      params: ['goods_id'],
      filters: [],
      option:{},
    },{
      label: "操作",
      type: "action",
      field: "action",
      tips: false,
      headTips: "提示！",
      labelWidth: "400",
      option: [{
        label: "删除",
        callback: {
          type: 'message',
          url: ['goods', 'on_goods_delete'],
          params: ['goods_id'],
          config: {
            type: 'warning',
            title: '系统提示',
            content: '此操作将永久删除删除文件不可恢复，是否继续！',
            confirm: '继续',
            cancel: '取消',
            confirmTips: {
              type: 'success',
              message: '删除成功！',
            },
            cancelTips: {
              type: 'info',
              message: '您取消了删除！',
            }
          }
        },
        type: "primary",
        icon: "",
      }, {
        label: "发货",
        callback: {
          type: "alert",
          rule: [{
            field: "order_status",
            equality: " == 1"
          }],
          config: alert_form
        },
        type: "primary",
        icon: "",
      }, {
        label: "修改",
        callback: {
          type: 'target',
          path: 'goods_fix',
          params: ['goods_id', 'goods_sn']
        },
        type: "primary",
        icon: "",
      }, {
        label: "查看",
        callback: {
          type: "alert",
          config: alert_table
        },
        type: "primary",
        icon: "",
      }],
      sortable: false,
    }],
    model: 'input',
    selection: false,
    gather: '',
    fields: '',
  },
  handle: content,
  components: [{
    title: "设置属性",
    handle: attribute,
    tool: tool
  }, {
    title: "数据绑定",
    handle: dataBind,
    tool: false
  }],
  amount: 999,
  title: '表格',
  icon: 'el-icon-eleme'
}
